﻿namespace Home
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.ServiceModel.Activation;
    using System.Web;
    using System.Web.Http;
    using System.Web.Mvc;
    using System.Web.Routing;
    using System.Web.Security;
    using System.Web.SessionState;
    using Home.Services;
    using Home.Services.ProductServices;

    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RegisterRoutes(RouteTable.Routes);
        }

        private static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "",
                defaults: new { controller = "Home", action = "Index" }
            );

            // TODO: add login function
            // routes.MapRoute(
            //     name: "Login",
            //     url: "login",
            //     defaults: new { controller = "Account", action = "Login" }
            // );

            // routes.MapRoute(
            //     name: "LoginCallback",
            //     url: "login-callback",
            //     defaults: new { controller = "Account", action = "LoginCallback" }
            // );

            // routes.MapRoute(
            //     name: "LoginFailure",
            //     url: "login-failure",
            //     defaults: new { controller = "Account", action = "LoginFailure" }
            // );

            // routes.MapRoute(
            //     name: "LogOff",
            //     url: "logoff",
            //     defaults: new { controller = "Account", action = "LogOff" }
            // );

            routes.Add(new ServiceRoute("services/productwebservice", new WebsiteServiceHostFactory(), typeof(ProductService)));
        }
    }
}